package br.elsa.survey.view.beans.managed.tests;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import br.elsa.survey.domain.questions.DiscursiveQuestion;
import br.elsa.survey.domain.questions.QuestionsFactory;
import br.elsa.survey.services.QuestionService;
import br.elsa.survey.view.beans.managed.DiscursiveQuestionCreationView;
import br.elsa.survey.view.beans.managed.RadioQuestionCreationView;
import br.elsa.survey.view.messages.ViewMessages;

/**
 * TDD test class for {@link RadioQuestionCreationView}
 * 
 * @author diego
 * @since 2010-10-03
 */
public class DiscursiveQuestionCreationViewControllerTest {

	/**
	 * Class under test
	 */
	private DiscursiveQuestionCreationView viewHandler;

	@Mock
	private QuestionService questionService;

	@Mock
	private DiscursiveQuestion newQuestion;

	@Mock
	private ViewMessages viewMessages;

	@Mock
	private QuestionsFactory factory;

	@Before
	public void setUp() throws Exception {
		MockitoAnnotations.initMocks(this);
		this.viewHandler = new DiscursiveQuestionCreationView(newQuestion, factory, questionService, viewMessages);
	}

	@Test
	public void resetComponentShoudResetNewComponentState() {
		DiscursiveQuestion resetedQuestion = mock(DiscursiveQuestion.class);
		when(factory.createDiscursiveQuestion()).thenReturn(resetedQuestion);

		viewHandler.resetViewState();

		Assert.assertEquals(resetedQuestion, viewHandler.getNewQuestion());
	}
}
